<html>
<head>
<script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script>
<style>
html {
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
color: #333;
}
table {
border-collapse: separate;
border-spacing: 2px;
}
tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}
* {
  font-size: 12px;
margin: 0;
padding: 0;
}
.list2 table {
border: 1px solid #D5D5D5;
}
.list2 {
line-height: 27px;
color: #333;
font-weight: normal;
display: none;
border-collapse: collapse;
}
.list2 td {
text-align: center;
}
.required{
  color:#FF0000
}
.list2 .textright {
text-align: right;
text-indent: 5px;
padding-right: 5px;
width: 20%;
}
.list2 .textleft {
text-align: left;
padding-left: 5px;
}
.submit_button {
background: url(catalog/view/theme/default/images/submit_buttonbg.png) repeat-x center left;
border: 0;
color: white;
height: 23px;
margin: 0 auto;
cursor: pointer;
width: 100px;
}
</style>
</head>
<body>
  <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
      <table width="100%" cellpadding="0" cellspacing="0" class="list2" style="display: table">
        <tr>
          <td class="textright"><font class="required">*</font><?php echo $entry_firstname; ?></td>
          <td class="textleft"><input type="text" name="firstname" value="<?php echo $firstname; ?>" />
            <?php if ($error_firstname) { ?>
            <span class="error"><?php echo $error_firstname; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td class="textright"><span class="required">*</span> <?php echo $entry_lastname; ?></td>
          <td class="textleft"><input type="text" name="lastname" value="<?php echo $lastname; ?>" />
            <?php if ($error_lastname) { ?>
            <span class="error"><?php echo $error_lastname; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td class="textright"><?php echo $entry_company; ?></td>
          <td class="textleft"><input type="text" name="company" value="<?php echo $company; ?>" /></td>
        </tr>
        <tr style="display: <?php echo ($company_id_display ? 'table-row' : 'none'); ?>;">
          <td class="textright"><?php echo $entry_company_id; ?></td>
          <td class="textleft"><input type="text" name="company_id" value="<?php echo $company_id; ?>" />
            <?php if ($error_company_id) { ?>
            <span class="error"><?php echo $error_company_id; ?></span>
            <?php } ?></td>
        </tr>
        <tr style="display: <?php echo ($tax_id_display ? 'table-row' : 'none'); ?>;">
          <td class="textright"><?php echo $entry_tax_id; ?></td>
          <td class="textleft"><input type="text" name="tax_id" value="<?php echo $tax_id; ?>" />
            <?php if ($error_tax_id) { ?>
            <span class="error"><?php echo $error_tax_id; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td class="textright"><span class="required">*</span> <?php echo $entry_address_1; ?></td>
          <td class="textleft"><input type="text" name="address_1" value="<?php echo $address_1; ?>" />
            <?php if ($error_address_1) { ?>
            <span class="error"><?php echo $error_address_1; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td class="textright"><?php echo $entry_address_2; ?></td>
          <td class="textleft"><input type="text" name="address_2" value="<?php echo $address_2; ?>" /></td>
        </tr>
        <tr>
          <td class="textright"><span class="required">*</span> <?php echo $entry_city; ?></td>
          <td class="textleft"><input type="text" name="city" value="<?php echo $city; ?>" />
            <?php if ($error_city) { ?>
            <span class="error"><?php echo $error_city; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td class="textright"><span id="postcode-required" class="required">*</span> <?php echo $entry_postcode; ?></td>
          <td class="textleft"><input type="text" name="postcode" value="<?php echo $postcode; ?>" />
            <?php if ($error_postcode) { ?>
            <span class="error"><?php echo $error_postcode; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td class="textright"><span class="required">*</span> <?php echo $entry_country; ?></td>
          <td class="textleft"><select name="country_id">
              <option value=""><?php echo $text_select; ?></option>
              <?php foreach ($countries as $country) { ?>
              <?php if ($country['country_id'] == $country_id) { ?>
              <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
              <?php } else { ?>
              <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
              <?php } ?>
              <?php } ?>
            </select>
            <?php if ($error_country) { ?>
            <span class="error"><?php echo $error_country; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td class="textright"><span class="required">*</span> <?php echo $entry_zone; ?></td>
          <td class="textleft"><select name="zone_id">
            </select>
            <?php if ($error_zone) { ?>
            <span class="error"><?php echo $error_zone; ?></span>
            <?php } ?></td>
        </tr>
        <tr>
          <td colspan="2" style="color:#1c89d0;" align="left"><?php echo $entry_default; ?>
            <?php if ($default) { ?>
            <input type="radio" name="default" value="1" checked="checked" />
            <?php echo $text_yes; ?>
            <input type="radio" name="default" value="0" />
            <?php echo $text_no; ?>
            <?php } else { ?>
            <input type="radio" name="default" value="1" />
            <?php echo $text_yes; ?>
            <input type="radio" name="default" value="0" checked="checked" />
            <?php echo $text_no; ?>
            <?php } ?></td>
        </tr>
        <tr>
          <td colspan=2 align="middle">
            <input type="submit" value="<?php echo $button_continue; ?>" class="submit_button" />
          </td>
        </tr>
      </table>
  </form>
<script type="text/javascript"><!--
$('select[name=\'country_id\']').bind('change', function() {
	$.ajax({
		url: 'index.php?route=account/address/country&country_id=' + this.value,
		dataType: 'json',
		beforeSend: function() {
			$('select[name=\'country_id\']').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
		},		
		complete: function() {
			$('.wait').remove();
		},			
		success: function(json) {
			if (json['postcode_required'] == '1') {
				$('#postcode-required').show();
			} else {
				$('#postcode-required').hide();
			}
			
			html = '<option value=""><?php echo $text_select; ?></option>';
			
			if (json['zone'] != '') {
				for (i = 0; i < json['zone'].length; i++) {
        			html += '<option value="' + json['zone'][i]['zone_id'] + '"';
	    			
					if (json['zone'][i]['zone_id'] == '<?php echo $zone_id; ?>') {
	      				html += ' selected="selected"';
	    			}
	
	    			html += '>' + json['zone'][i]['name'] + '</option>';
				}
			} else {
				html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
			}
			
			$('select[name=\'zone_id\']').html(html);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});
$('select[name=\'country_id\']').trigger('change');
//--></script> 
</body>
</html>